import {getStationById, getTerminalById, getUserInfo, getWorkOrders, toastInfo} from "../../utils/common";

let app = getApp();

Page({
    data: {},
    onShow() {
        this.getTabBar().init();
    },
    click: function () {
        // 只允许从相机扫码
        wx.scanCode({
            onlyFromCamera: true,
            async success(res) {
                wx.showLoading({mask: true})
                console.log("扫描的二维码为", res.result)
                let response = await getStationById(res.result);
                if (response.isSuccess) {
                    if (response.resultData.null) {
                        toastInfo("根据二维码未找到基站");
                    } else {
                        let station = null;
                        if (response.resultData.hasOwnProperty("2")) {
                            station = response.resultData["2"]
                        } else if (response.resultData.hasOwnProperty("3")) {
                            station = response.resultData["3"]
                        } else {
                            toastInfo("基站未出库或者连通");
                            return;
                        }
                        console.log("station", station)
                        app.globalData.currentStation = station
                        wx.hideLoading()
                        wx.navigateTo({
                            url: "/pages/station/station"
                        })

                    }
                }
            },
            fail(err) {
                toastInfo("扫码失败!")
            },

        })
    },

    onLoad: async function (options) {
        // 获取工单 列表
        // let res = await getWorkOrders();
        // if (res.isSuccess) {
        //     console.log("res.resultData", res.resultData)
        // }


    }
});

"o2Lgh5XKJ-aqrSodKwuqAqHrCqkk"
